home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Freeware / DiskMaster / Rexx / ArcMast.rexx next >
OS/2 REXX Batch file  |  2002-10-27  |  3KB  |  131 lines

  1. /* $VER: ArcMast.rexx 2.0 (25.10.97) by J. Tierney
  2.  
  3.   Archive Master 2.0
  4.   10/25/97  J. Tierney
  5.  
  6.   Function:  Extract, list, or test many types of archives.
  7.  
  8.   Usage:  ArcMast.rexx <file> <opt> [<dest>]
  9.  
  10.     <file> - The archive to operate on.
  11.  
  12.     <opt>  - E \
  13.            - X - Extract the archive's contents.
  14.            - L - List the archive's contents.
  15.            - T - Test the archive.
  16.  
  17.     <dest> - Destination path.  Optional; if not specified then <file>'s path
  18.             (assuming one was given) is used.
  19.  
  20.  
  21.   Expanding ArcMast:
  22.   Add the following lines to add new archivers to ArcMast.rexx.
  23.  
  24.   arc.<index>.ext   = '<The filename extension used to recognize an archive.>'
  25.   arc.<index>.unarc = '<Command to extract the archive.>'
  26.   arc.<index>.list  = '<Command to list the archive.>'
  27.   arc.<index>.test  = '<Command to test the archive.>'
  28.  
  29.   If an option isn't supported, then leave that entry blank.  For example:
  30.     arc.3.test = ''
  31.   means there is no test option.
  32.  
  33.   And then set the variable "arc.count" to the last index number used.
  34. */
  35.  
  36. arc.count = 6  /*  Set this to the last index number used.  */
  37.  
  38. arc.0.ext   = '.LHA'      /*  The archive's extension. */
  39. arc.0.unarc = 'C:LZX x'   /*  Extract command.         */
  40. arc.0.list  = 'C:LZX v'   /*  List command.            */
  41. arc.0.test  = 'C:LZX t'   /*  Test command.            */
  42.  
  43. arc.1.ext   = '.LZX'
  44. arc.1.unarc = 'C:LZX x'
  45. arc.1.list  = 'C:LZX v'
  46. arc.1.test  = 'C:LZX t'
  47.  
  48. arc.2.ext   = '.LZH'
  49. arc.2.unarc = 'C:LZX x'
  50. arc.2.list  = 'C:LZX v'
  51. arc.2.test  = 'C:LZX t'
  52.  
  53. arc.3.ext   = '.ZIP'
  54. arc.3.unarc = 'C:UnZip'
  55. arc.3.list  = 'C:UnZip -l'
  56. arc.3.test  = 'C:UnZip -t'
  57.  
  58. arc.4.ext   = '.ZOO'
  59. arc.4.unarc = 'C:Zoo x'
  60. arc.4.list  = 'C:Zoo l'
  61. arc.4.test  = 'C:Zoo t'
  62.  
  63. arc.5.ext   = '.ARC'
  64. arc.5.unarc = 'C:ArcX -x'
  65. arc.5.list  = 'C:ArcX -l'
  66. arc.5.test  = 'C:ArcX -t'
  67.  
  68. arc.6.ext   = '.DL'
  69. arc.6.unarc = 'SYS:Graphics/UnDL'
  70. arc.6.list  = ''                   /*  No list option. */
  71. arc.6.test  = ''                   /*  No test option. */
  72.  
  73. /*
  74. Copy and fill in the following lines to expand ArcMast.rexx.
  75. Don't forget to set the arc.count variable, too!
  76.  
  77. arc..ext   = ''   /*  The archive's extension. */
  78. arc..unarc = ''   /*  Extract command.         */
  79. arc..list  = ''   /*  List command.            */
  80. arc..test  = ''   /*  Test command.            */
  81.  
  82. */
  83.  
  84.  
  85.  
  86.  
  87. /*  *** Program Begins Here *** */
  88.  
  89. PARSE ARG fname opt dest .
  90.  
  91. opt = UPPER(opt)
  92.  
  93. IF dest = '' THEN DO
  94.   x = POS('/', fname)
  95.   IF x = 0 THEN x = POS(':', fname)
  96.   IF x ~=0 THEN dest = LEFT(fname, x)
  97. END
  98.  
  99. x = LASTPOS('.', fname)
  100. fext = UPPER(SUBSTR(fname, x))
  101.  
  102. arcidx = -1
  103. DO i = 0 TO arc.count
  104.   IF arc.i.ext = fext THEN DO
  105.     arcidx = i
  106.     LEAVE
  107.   END
  108. END
  109. IF arcidx = -1 THEN DO
  110.   SAY 'ERROR:  Unknown extension -' fext
  111.   EXIT 10
  112. END
  113.  
  114. SELECT
  115.   WHEN opt = 'E' | opt = 'X' THEN cmd = arc.arcidx.unarc
  116.   WHEN opt = 'L' THEN cmd = arc.arcidx.list
  117.   WHEN opt = 'T' THEN cmd = arc.arcidx.test
  118.   OTHERWISE DO
  119.     SAY 'ERROR:  Unknown option -' opt
  120.     EXIT 10
  121.   END
  122. END
  123.  
  124. IF cmd = '' THEN DO
  125.   SAY 'ERROR:  Option' opt 'is not available for' fext 'archives.'
  126.   EXIT 5
  127. END
  128.  
  129. CALL PRAGMA('D', dest)
  130. ADDRESS COMMAND cmd fname
  131.